package com.bh.web.controller.vehicle;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.vehicle.domain.JcCarrier;
import com.bh.vehicle.service.IJcCarrierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 承运商Controller
 * 
 * @author slx
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/vehicle/carrier")
public class JcCarrierController extends BaseController
{
    @Autowired
    private IJcCarrierService jcCarrierService;

    /**
     * 查询承运商列表
     */
    @ApiOperation("查询承运商列表")
    @PreAuthorize("@ss.hasPermi('vehicle:carrier:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcCarrier jcCarrier)
    {
        startPage();
        List<JcCarrier> list = jcCarrierService.selectJcCarrierList(jcCarrier);
        return getDataTable(list);
    }


    /**
     * 查询承运商列表
     */
    @ApiOperation("查询承运商列表")
    @GetMapping("/allList")
    public AjaxResult allList(JcCarrier jcCarrier)
    {
        List<JcCarrier> list = jcCarrierService.selectJcCarrierList(jcCarrier);
        return AjaxResult.success(list);
    }

    /**
     * 获取承运商详细信息
     */
    @ApiOperation("获取承运商详细信息")
    @PreAuthorize("@ss.hasPermi('vehicle:carrier:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcCarrierService.selectJcCarrierById(id));
    }

    /**
     * 新增承运商
     */
    @ApiOperation("新增承运商")
    @PreAuthorize("@ss.hasPermi('vehicle:carrier:add')")
    @Log(title = "承运商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcCarrier jcCarrier)
    {
        return toAjax(jcCarrierService.insertJcCarrier(jcCarrier));
    }

    /**
     * 修改承运商
     */
    @ApiOperation("修改承运商")
    @PreAuthorize("@ss.hasPermi('vehicle:carrier:edit')")
    @Log(title = "承运商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcCarrier jcCarrier)
    {
        return toAjax(jcCarrierService.updateJcCarrier(jcCarrier));
    }

    /**
     * 删除承运商
     */
    @ApiOperation("删除承运商")
    @PreAuthorize("@ss.hasPermi('vehicle:carrier:remove')")
    @Log(title = "承运商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcCarrierService.deleteJcCarrierByIds(ids));
    }
}
